﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace DemoGame1
{
    public class Character : VisibleGameEntity
    {
        public const int STAND = 0;
        private float _SPEED = 20.0f;

        public float SPEED
        {
            get { return _SPEED; }
            set { _SPEED = value; }
        }
        public const int WALK = 1;
        public const int ATK = 2;
        public const int DOWN = 3;
        public const int LEFT = 4;
        public const int RIGHT = 5;
        public const int UP = 6;
        public const int SKILL = 7;
        public const int DAMAGED = 8;
        public const int DEAD = 9;
        public const int WAKEUP = 10;
        public int _status = STAND;
        public Texture2D[] standSequence;
        public Texture2D[] walkSequence;
        public Texture2D[] attackSequence;
        public Texture2D[] deadSequence;
        public ContentManager content;
        public Texture2D[] damagedSequence;
        public int lastDirection = RIGHT;
        public int dead = 0;
        private int _hp;

        public int HP
        {
            get { return _hp; }
            set { _hp = value; }
        }

        public int Status
        {

            get { return _status; }
            set { _status = value; }
        }
        protected Texture2D[] CreateTexture(string strTexturePrefix, int nTextures)
        {
          
            string[] strTexture = new string[nTextures];
            Texture2D[] textures = new Texture2D[nTextures];
            for (int i = 0; i < nTextures; i++)
            {
                strTexture[i] = strTexturePrefix + (i + 1).ToString();
                textures[i] = content.Load<Texture2D>(strTexture[i]);
            }
            return textures;
        }
       virtual public void SetFrameSequence(int type)
        {
            switch (type)
            {
                case STAND:
                    Sprites[0].Textures = standSequence;
                    break;
                case WALK:
                    Sprites[0].Textures = walkSequence;
                    break;
                case ATK:
                    Sprites[0].Textures = attackSequence;
                    break;

                case DEAD:
                    Sprites[0].Textures = deadSequence;
                    break;
                case DAMAGED:
                    Sprites[0].Textures = damagedSequence;
                    break;
                
            }

        }
       public override void Draw(SpriteBatch spriteBatch, GameTime gameTime)
       {
           if (Drawbound)
           {
               Texture2D texture = content.Load<Texture2D>("bound");
               spriteBatch.Draw(texture, BoundRect, Color.White);
           }

           SpriteFont sf = content.Load<SpriteFont>("myfont");
           //sb.DrawString(sf, "HP: " + HP, TopLeft, Color.Black);
           base.Draw(spriteBatch, gameTime);
       }
    }
}
